package com.anasoft.os.s4j.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.anasoft.os.s4j.SeleniumSuiteRunner;
import com.thoughtworks.selenium.Selenium;

/**
 * Specifies that the target test class should be run within a {@link Selenium}
 * session.
 * 
 * @see ErrorReporting
 * @see EmbeddedSeleniumServer
 * 
 * @author vojtech.szocs
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface SeleniumSession {

    /**
     * The host on which Selenium server resides.
     */
    String serverHost() default "localhost";

    /**
     * The port on which Selenium server is listening.
     */
    int serverPort() default 4444;

    /**
     * Command string used to launch the browser.
     * <p>
     * For example:
     * <ul>
     * <li><tt>*firefox</tt>
     * <li><tt>c:\\program files\\internet explorer\\iexplore.exe</tt>
     * </ul>
     */
    String browserString();

    /**
     * Starting URL that consists of domain name only.
     * <p>
     * Selenium resources as well as the application under test are served
     * through this URL by Selenium server.
     * <p>
     * For example:
     * <ul>
     * <li><tt>http://localhost:8080</tt>
     * <li><tt>http://my.domain.com</tt>
     * </ul>
     */
    String browserUrl();

    /**
     * Timeout for actions that require waiting, e.g. <tt>open</tt> and
     * <tt>waitFor*</tt> actions.
     */
    int commandTimeoutInSeconds() default 60;

    /**
     * Command execution speed - the delay which follows each Selenium command.
     */
    int executionSpeedInMillis() default 0;

    /**
     * Used by {@link SeleniumSuiteRunner}. If set to <tt>true</tt>, any tests
     * that should normally run after some other test failed, will be skipped
     * instead.
     * <p>
     * This option is particularly useful for test suites where tests depend on
     * each other and a test failure should "stop" the entire test suite
     * execution.
     */
    boolean skipSubsequentTestsOnFailure() default false;

    /**
     * Error reporting configuration in relation to failed tests.
     */
    ErrorReporting errorReporting() default @ErrorReporting(enabled = false);

    /**
     * Embedded Selenium server configuration.
     */
    EmbeddedSeleniumServer embeddedServer() default @EmbeddedSeleniumServer(enabled = false);

}
